#1.4

uniform sampler2D pointSprite;
uniform float lod;


varying vec4 myPosition;
varying vec4 myInfo;


void main(){

	// BLUR
	float textureLevel = 0.0;
	float alphaFactor = 0.8;
	
	float step = -myPosition.z/100.0;
	if (myPosition.z>1.0) {
		step = 0.01;
		textureLevel = 0.0;
		alphaFactor = 0.6;
	}
	
	float lod = -myPosition.z;
	lod = 1.0;
	
	
	vec2 spriteCoord = gl_TexCoord[0].xy + vec2 (0, 0.25*(myInfo.x-1.0));
	vec4 outColor = texture2D (pointSprite, spriteCoord)*myPosition.z;
	//vec4 outColor = texture2D (pointSprite, spriteCoord, lod);
	
	/*
	outColor += 0.15018*texture2D(pointSprite,  spriteCoord, lod);
	outColor += 0.09524*texture2D(pointSprite,  spriteCoord+vec2(-step,0),   lod);
	outColor += 0.09524*texture2D(pointSprite,  spriteCoord+vec2( step,0),   lod);
	outColor += 0.09524*texture2D(pointSprite,  spriteCoord+vec2( 0, -step), lod);
	outColor += 0.09524*texture2D(pointSprite,  spriteCoord+vec2( 0,  step), lod);
	
	outColor += 0.05861*texture2D(pointSprite,  spriteCoord+vec2( step,  step), lod);
	outColor += 0.05861*texture2D(pointSprite,  spriteCoord+vec2(-step,  step), lod);
	outColor += 0.05861*texture2D(pointSprite,  spriteCoord+vec2(-step, -step), lod);
	outColor += 0.05861*texture2D(pointSprite,  spriteCoord+vec2( step, -step), lod);
	
	outColor += 0.02564*texture2D(pointSprite,  spriteCoord+vec2 ( 2.0*step, 0), lod);
	outColor += 0.02564*texture2D(pointSprite,  spriteCoord+vec2 (-2.0*step, 0), lod);
	outColor += 0.02564*texture2D(pointSprite,  spriteCoord+vec2 (0, 2.0*step), lod);
	outColor += 0.02564*texture2D(pointSprite,  spriteCoord+vec2 (0,-2.0*step), lod);
	
	outColor += 0.01465*texture2D(pointSprite,  spriteCoord+vec2 ( 2.0*step, step), lod);
	outColor += 0.01465*texture2D(pointSprite,  spriteCoord+vec2 ( 2.0*step,-step), lod);
	outColor += 0.01465*texture2D(pointSprite,  spriteCoord+vec2 (-2.0*step, step), lod);
	outColor += 0.01465*texture2D(pointSprite,  spriteCoord+vec2 (-2.0*step,-step), lod);
	outColor += 0.01465*texture2D(pointSprite,  spriteCoord+vec2 ( step, 2.0*step), lod);
	outColor += 0.01465*texture2D(pointSprite,  spriteCoord+vec2 ( step,-2.0*step), lod);
	outColor += 0.01465*texture2D(pointSprite,  spriteCoord+vec2 (-step, 2.0*step), lod);
	outColor += 0.01465*texture2D(pointSprite,  spriteCoord+vec2 (-step,-2.0*step), lod);
	
	outColor += 0.00366*texture2D(pointSprite,  spriteCoord+vec2 ( 2.0*step,  2.0*step), lod);
	outColor += 0.00366*texture2D(pointSprite,  spriteCoord+vec2 (-2.0*step,  2.0*step), lod);
	outColor += 0.00366*texture2D(pointSprite,  spriteCoord+vec2 (-2.0*step, -2.0*step), lod);
	outColor += 0.00366*texture2D(pointSprite,  spriteCoord+vec2 ( 2.0*step, -2.0*step), lod);
	*/

	/*
	vec4 outColor = 0.25*texture2D(pointSprite, spriteCoord, lod);
	outColor += 0.125*texture2D(pointSprite,  spriteCoord+vec2(-step,0), lod);
    outColor += 0.125*texture2D(pointSprite,  spriteCoord+vec2( step,0), lod);
	outColor += 0.125*texture2D(pointSprite,  spriteCoord+vec2(0,step), lod);
    outColor += 0.125*texture2D(pointSprite,  spriteCoord+vec2(0,-step), lod);
    outColor += 0.0625*texture2D(pointSprite, spriteCoord+vec2(step,step), lod);
	outColor += 0.0625*texture2D(pointSprite, spriteCoord+vec2(step,-step), lod);
	outColor += 0.0625*texture2D(pointSprite, spriteCoord+vec2(-step,-step), lod);
	outColor += 0.0625*texture2D(pointSprite, spriteCoord+vec2(-step,step), lod);
	*/
	
	
	/*
	0.00366		0.01465		0.02564		0.01465		0.00366
	0.01465		0.05861		0.09524		0.05861		0.01465
	0.02564		0.09524		0.15018		0.09524		0.02564
	0.01465		0.05861		0.09524		0.05861		0.01465
	0.00366		0.01465		0.02564		0.01465		0.00366
	*/
	//outColor = texture2D(pointSprite, spriteCoord, lod);
	gl_FragColor = vec4(outColor.xyz, outColor.w); // * (1.0+myPosition.z);
	//gl_FragColor = vec4(1,1,0,1); // * (1.0+myPosition.z);
}